using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter29
{
	/// <summary>
	/// Example03: The Magnetic Dipole Moment of a Coil
	/// A rectangular coil of dimensions 5.40 cm \times 8.50 cm  
	/// consists of 25 turns of wire and 
	/// carries a current of 15.0 mA. A 0.350-T 
	/// magnetic field is applied parallel to the loop.
	/// (A)	Calculate the magnitude of its magnetic dipole moment.
	/// (B)	What is the magnitude of the torque acting on the loop?
	/// </summary>
	public class Example03
	{
		public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.AreaVector A = new L.AreaVector();
			A.Z = 5.4E-2*8.5E-2*25.0;
			L.MagneticField B = new L.MagneticField();
			B.X = 0.35;
			L.ElectricCurrent I = new L.ElectricCurrent();
			I.A = 15.0E-3;
			//(A)
			L.MagneticDipoleMoment mu 
				= new L.MagneticDipoleMoment(I,A);
			result+=Convert.ToString(mu.X)+"  i+ "
				+Convert.ToString(mu.Y)+"  j+  "+
				Convert.ToString(mu.Z)+"  k\r\n";
			//(B)
			L.Torque tau = mu.TorqueInMagneticField(B);
			result+=Convert.ToString(tau.X)+"  i+ "
				+Convert.ToString(tau.Y)+"  j+  "+
				Convert.ToString(tau.Z)+"  k";
		}		
	}
}
